<?php
	define('CONFIG_FILE',true);
	include '../config.php';
	
	define('DB_FILE',true);
	require_once '../Tool/DB/SqlDBManager.class.php';
	
	session_start();
	if (empty($_SESSION["userType"])) {
		$url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
	}

	if($_SESSION["userType"]=="Therapy Assistant"){
        $url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
    }

	$Username = $_REQUEST['Username'];

	$sqlDBManager = new SqlDBManager();

	$sql = "delete from user where Username=?";

	$parameters = array($Username);
	$res=$sqlDBManager->execute_dml($sql,$parameters);

	//close connection
  	$sqlDBManager->close_connect();

	if ($res>0){
		echo json_encode(array('success'=>true));
	} else {
		echo json_encode(array('msg'=>'Remove user failed due to database error.'));
	}
?>